using ServiceStack.Commands;
using System;
using System.Collections.Generic;
using System.Threading;
namespace ServiceStack.Support
{
	public class CommandResultsHandler<T> : ICommandExec, ICommand<bool>
	{
		private readonly List<T> results;
		private readonly ICommandList<T> command;
		private readonly AutoResetEvent waitHandle;
		public CommandResultsHandler(List<T> results, ICommandList<T> command, AutoResetEvent waitHandle)
		{
			this.results = results;
			this.command = command;
			this.waitHandle = waitHandle;
		}
		public bool Execute()
		{
			this.results.AddRange(this.command.Execute());
			this.waitHandle.Set();
			return true;
		}
	}
}
